﻿using System;

namespace Skynet.CommonLibrary.ExceptionEx
{
    public static  class  ExceptionFactory
    {
        static readonly ExceptionManager Manager;
        static ExceptionFactory()
        { Manager = new ExceptionManager(); }

        /// <summary>
        /// 处理异常 处理方式默认
        /// </summary>
        /// <param name="ex"></param>
        public static void ProcessException(this Exception ex)
        {
            Manager.ProcessException(ex, string.Empty, string.Empty);
        }

        /// <summary>
        /// 按照layerName 处理相应异常
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="layerName">层名称</param>
        /// <param name="msg">友好提示</param>
       public  static void ProcessException(this Exception ex,string layerName,string msg)
        {
            Manager.ProcessException(ex, layerName, msg);
        }
        /// <summary>
       /// 按照layerName 处理相应异常
        /// </summary>
       /// <param name="ex">异常信息</param>
       /// <param name="layerName">层名称</param>
       public static void ProcessException(this Exception ex, string layerName)
       {
           Manager.ProcessException(ex, layerName,ex.Message);
       }

        /// <summary>
        /// 根据异常编号 处理异常
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="exId">异常编号</param>
       public static void ProcessException(this Exception ex, int exId)
       {
           Manager.ProcessException(ex, exId);
       }
    }
}
